import os
import sys
sys.stdout.reconfigure(encoding='utf-8')

from langchain_openai import ChatOpenAI
from browser_use import Agent

import asyncio

llm = ChatOpenAI(
    api_key=os.getenv("DASHSCOPE_APIKEY"),
    base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
    model="qwen-max",
)


async def main(prompt):
  agent = Agent(
      task=prompt,
      llm=llm,
  )
  return await agent.run()

def run(prompt):
  """Run the agent with the given prompt."""
  return asyncio.run(main(prompt))


if __name__ == '__main__':
  print(run(""))
